<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 装饰器的实现
        class Circle {
            draw() { //行为
                console.log("画一个圆");
            }
        }
        // 使用装饰器添加边框
        class Decorator {
            constructor(circle) {
                this.circle = circle;
            }
            draw() {
                this.circle.draw();
                this.setBorderCircle(this.circle); //装饰品方法
            }
            setBorderCircle(circle) {
                console.log("绘制边框");
            }
        }

        var circle = new Circle();
        new Decorator(circle).draw();

        
    </script>
</body>
</html>